package cn.itcast.jdbc;

import cn.itcast.utils.JDBCutils;

import java.sql.*;

/**
 * 版权：卓灿教育集团 版权所有
 * author :赵航
 *
 * @e-mail: zhaohangcn@gmail.com
 * time：2021/2/16
 * describe ：${TODO}
 */
public class JdbcDome4 {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        try {
            connection= JDBCutils.getConnection();
            String sql = "select * from account";
            statement = connection.createStatement();
            resultSet = statement.executeQuery(sql);

            //判断next是否是最后一行的末尾
            while (resultSet.next()) {
                int id = resultSet.getInt(1);
                String name = resultSet.getString("name");
                double balance = resultSet.getDouble(3);

                System.out.println(id + "===" + name + "===" + balance);
            }


        } catch (Exception e) {
            e.printStackTrace();
        } finally {
          JDBCutils.colse(resultSet,statement,connection);
        }
    }
}
